var section = document.getElementsByTagName('section')[0],
				li = section.getElementsByTagName('li'),
				Action = section.getElementsByClassName('action')[0],
				Start = Action.getElementsByClassName('kai_shi')[0],
				clock = null;
var music = document.getElementsByTagName("audio")[0];
var lable_mus = document.getElementsByTagName("label")[0];
var zj_bg = document.getElementsByClassName("cj_bg")[0];
var isClick = true;//开关
var arr = [0,1,2,4,7,6,5,3];//顺时针方向
var m=null;
var n=0;
var i =	0;
			function start() {
				var num = Math.floor(Math.random() * li.length) + 20;//随机数
				if (isClick) {
					isClick = !isClick;
					console.log(num)
					if(i < num) {
						//选择定时器
						clock = setInterval(function() {
							//初始化
							for(var j = 0; j < li.length; j++) {
								li[j].classList.remove("active");
							}
							if(n == arr.length){
								n=0;
							}
						 	m = arr[n];
						 	n++;
							//转动到添加放大效果
							li[m].classList.add("active");
							
							i++;
							console.log(i)
							if(i === num) {
								clearInterval(clock);
								//抽中奖弹出兑换窗口
								zj_bg.style.display = "block";
								li[m].classList.add("zhong_jiang");
//								alert("恭喜您中奖了！")
							}
						}, 250);
					}
				}
			}
			//开始抽奖按钮
			Start.addEventListener("click",function(e){
				Start.classList.remove("sta_ani")
				start();
				console.log(e)
			})
			//音乐按钮
			lable_mus.addEventListener("click",function(e){
				if (music.paused) {
					music.play();
					document.getElementsByClassName("you")[0].classList.add("anim");
				}else{
					music.pause();
					document.getElementsByClassName("you")[0].classList.remove("anim");
				}
			})

var Info = document.getElementsByClassName("zuo")[0];
var guiZe = document.getElementsByClassName("gz_info")[0];
var close = guiZe.getElementsByClassName("close")[0];
var dj_btn = section.getElementsByClassName("big_btn")[0];
var duiJiang = document.getElementById("dui_jiang");
var close2 = duiJiang.getElementsByClassName("close")[0];
//规则说明按钮
Info.addEventListener("click",function(){
	guiZe.classList.add("gz_ani");
	guiZe.style.display = "block";
})
close.addEventListener("click",function(){
	guiZe.style.display = "none";
})
//兑奖按钮
dj_btn.addEventListener("click",function(){
	duiJiang.classList.add("gz_ani");
	duiJiang.style.display = "block";
})
close2.addEventListener("click",function(){
	duiJiang.style.display = "none";
	location.href = "index.html";
})